var toyApp=angular.module('toyApp');
//我的预约列表
toyApp.controller('wishlistCtl', [
	'$state',
	'$scope',
	'toyService',
	'broadcastBetweenCtrls',
	function($state,$scope,toyService,broadcastBetweenCtrls){
		$scope.redirectexpress=function(){
			$state.go('index.express');
		}
	$scope.$on('ADD_ORDER_SUCCESS',function(){
		wishList();
	});
	$scope.print=function(){  
               $("div#expressdetail").printArea();
            };  
	$scope.createorder=function(wishid){
		toyService('createorder',function(res){
			if(!res.success){
				alert(res.desc);
				
			}else{
				alert("创建订单成功，可进行快递操作！");
				$scope.$broadcast('ADD_ORDER_SUCCESS');
			}
		},{
			wishid:wishid
		});
	}
	$scope.setwishId=function (wishid){
		$scope.newishid=wishid;
	}
	$scope.createexpress=function(){
		toyService('creteexpress',function(res){
			if(!res.success){
				alert(res.desc);
				
			}else{
				alert("创建用户订单成功");
				$scope.$broadcast('ADD_ORDER_SUCCESS');
			}
		},{
			wishid:$scope.newishid,
			company:$scope.newcompany,
			courier:$scope.newcourier,
			excode:$scope.newexcode,
			exmobile:$scope.newexmobile
		});
	}


	var wishList=function(){
	toyService('queryWishList',function(res){
		if(!res.success){
			return false;
		}
		$scope.wishList=res.info;
	},{
		status:'w'
	});
	};
		$scope.timeStamp=new Date().getTime();
			$scope.$watch('timeStamp',function(){
		wishList();
	});
    var createorder=function(id){
    	toyService('createorder',function(res){
         if(!res.success){
         	return false;
         }
         alert("生成订单成功!");
    	},{})
    }


}]);


